var last_page;
var videotype = '55'
var titlestr = '精彩短片'
console.log("开始")
module.exports = {
    type: 'list',
    title: '丝瓜->类型选择',
    actions: [
        {
            title: '精彩短片',
            onClick: async function () {
                videotype = '55'
                this.refresh()
            }
        },
        {
            title: '高清无码',
            onClick: async function () {
                videotype = '1'
                this.refresh()
            }
        },
        {
            title: '制服诱惑',
            onClick: async function () {
                videotype = '5'
                this.refresh()
            }
        },
        {
            title: '当红女优',
            onClick: async function () {
                videotype = '9'
                this.refresh()
            }
        },
        {
            title: '国产自拍',
            onClick: async function () {
                videotype = '10'
                this.refresh()
            }
        },
        {
            title: '网络主播',
            onClick: async function () {
                videotype = '17'
                this.refresh()
            }
        },
        {
            title: '欧美AV',
            onClick: async function () {
                videotype = '16'
                this.refresh()
            }
        },
    ],
    searchRoute: $route('list'),
    async fetch({ args, page }) {
        console.log(titlestr)
        var resp;
        if (page == null) {
            resp = await $http.get(`https://sgjk3.com/api/videosort/` + videotype + `?orderby=new&page=1&uuid=48cf2ce1d253e8ee&device=0`)
            last_page = resp.data.rescont.last_page
            //console.log(typeof last_page + last_page)
        } else {
            if (page <= last_page) {
                resp = await $http.get(`https://sgjk3.com/api/videosort/` + videotype + `?orderby=new&page=${page || 1}&uuid=48cf2ce1d253e8ee&device=0`)
                //console.log(typeof last_page + last_page +"xiangmu2")

            } else if (page == last_page) {
                $ui.toast("最后一页了");
            } else {
                console.log(page + "超过已有数据 勿刷新！！！")
            }
        }
        if (resp != null) {
            var itmes = resp.data.rescont.data.map(data => ({
                style: 'live',
                title: data.title,
                image: data.coverpath,
                route: $route('xj/detail', {
                    id: data.id,
                    type: "xj",
                    detailimage: data.coverpath
                })
            }))
            return {
                nextPage: (page || 1) + 1,
                items: itmes
            }
        }


    }
}